/*
 * SimpleFileLogger.java  0.4.0 / Oct 23, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
package com.cute4j.logging.simple;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;

/**
 * Simple file logging.
 *
 * @author Slobodan Vrkacevic
 * @version 0.4.0
 */
public class SimpleFileLogger extends SimpleLogger {

// Public Constructors. --------------------------------------------------------

  /**
   * Constructs new FileLogger object.
   *
   * @throws FileNotFoundException if the log file could not be created
   */
  public SimpleFileLogger() throws FileNotFoundException {
    this(getLogFileName());
  }

  /**
   * Constructs new FileLogger object.
   *
   * @param fileName the log file name
   *
   * @throws FileNotFoundException if the log file could not be created
   */
  public SimpleFileLogger(String fileName) throws FileNotFoundException {
    this(fileName, true);
  }

  /**
   * Constructs new FileLogger object.
   *
   * @param fileName the log file name
   * @param append whether or not to append logs to the log file
   *
   * @throws FileNotFoundException if the log file could not be created
   */
  public SimpleFileLogger(String fileName, boolean append) throws
                                                        FileNotFoundException {
    super(new FileOutputStream(fileName, append));
  }

// Overridden Methods. ---------------------------------------------------------

  /**
   * {@inheritDoc}
   */
  public String getName() {
    return "Simple File Logger";
  }

// Private Static Methods. -----------------------------------------------------

  private static String getLogFileName() {
    return System.getProperty("cute4j.logging.file", "cute4j.log");
  }

}
